@echo off
setlocal
set source_project_name=%1

if "%source_project_name%"=="" (
   echo "Usage: %0 source_project_name [target_project_name]"
   exit /B 1
)

set target_project_name=%2

if "%target_project_name%"=="" set target_project_name=%source_project_name%


echo Copy binaries of %source_project_name% to _externals (to %target_project_name%)

set bin_folder=.\%source_project_name%\bin\Debug
set snapshot_folder=.\_externals\%target_project_name%\_latest

if not exist %bin_folder% (
   echo Folder "%bin_folder%" not found
   exit /b 2
)

if not exist %snapshot_folder% (
   mkdir "%snapshot_folder%"
) else (
   echo Deleting old files...
   rem Note there is .svn folder in the folder being deleted (be careful with recursive operations!)
   del "%snapshot_folder%\*" /Q
)

echo Copying new files...
copy "%bin_folder%\*" "%snapshot_folder%\*"

pause